package com.nbjtjc.safe.mapper.emg;

import com.nbjtjc.safe.model.emg.EmgDuty;
import com.nbjtjc.util.MyMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmgDutyMapper extends MyMapper<EmgDuty> {

    @Delete("delete  from emg_duty where plan_public_id=#{planPublicId}")
    int deleteByPlanPublicId(@Param("planPublicId") int planPublicId);
    List<EmgDuty> search(@Param("duty") EmgDuty emgDuty);

    @Select("SELECT emg_duty.*,sys_user.username as userName from emg_duty  " +
            "LEFT JOIN sys_user ON emg_duty.user_id=sys_user.user_id " +
            "where plan_public_id=#{planPublicId}")
    List<EmgDuty> findByPlanPublicId(@Param("planPublicId") int planPublicId);
}